from jobscrapy.items import JobscrapyItem
 
class JobSpider(scrapy.Spider):
    name = "job"
    allowed_domains = ["www.techlabplt.com"]
    start_urls = ["http://www.techlabplt.com:8080/BD-PC/zhaopin.html"]
 
    def parse(self, response):
        # print("返回的状态码信息为：", response.status)
        job_list = response.xpath("//*[@id='app']/ul/li")
 
        for job in job_list:
            # 获取得到各个数据字段
            job_item = JobscrapyItem()
            job_item['job_name'] = job.xpath("./div[1]/a/div[1]/span[1]/text()").extract_first()
            job_item['area'] = job.xpath("./div[1]/a/div[1]/span[2]/span/span/text()").extract_first()
            job_item['salary'] = job.xpath("./div[1]/a/div[2]/span/text()").extract_first()
            job_item['experiment'] = job.xpath("./div[1]/a/div[2]/ul/li[1]/text()").extract_first()
            job_item['skills'] = job.xpath("./div[2]/ul/li[1]/text()").extract_first()
            job_item['company_name'] = job.xpath("./div[1]/div/div[2]/h3/text()").extract_first().replace("\n", "").replace(" ", "")
            job_item['company_type'] = job.xpath("./div[1]/div/div[2]/ul/li[1]/text()").extract_first()
            job_item['company_type_boon'] = job.xpath("./div[2]/div/text()").extract_first()
            # 返回数据
            yield job_item
